#!/usr/bin/env node

//纯前端的
//get element
const q = document.querySelector,
      $ = q.bind(document);

const $width = $('[name="width"]'),
      $height = $('[name="height"]'),
      $calculate = $('[type="button"]'),
      $perimeter = $('[name="perimeter"]'),
      $area = $('[name="area"]');
// console.log($width, $height, $calculate, $area, $perimeter);

//get width ang height

//calculate
$calculate.onclick = () => {
    const w = Number($width.value),
          h = Number($height.value);    
    // console.log(w, h);

    const rect = {
        area: w * h,
        perimeter: 2 * (w + h)
    };

    //set area and perimeter
    $perimeter.value = rect.perimeter;
    $area.value = rect.area;
}



